# common/exceptions.py
from rest_framework.views import exception_handler
from rest_framework import status
from chatCompletion.entity.result.BaseResult import HttpResult


def custom_exception_handler(exc, context):
    response = exception_handler(exc, context)

    if response is not None:
        # return Response({'error': str(exc)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
        return HttpResult.error(message=str(exc), code=status.HTTP_500_INTERNAL_SERVER_ERROR)

    return response
